package com.example.WebTask1.Until;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DbUntil {
    static private String dbDriver;
    static private String dbUrl;
    static private String dbUser;
    static private String dbPassword;
    static {
        dbDriver="com.mysql.jdbc.Driver";
        dbUrl="jdbc:mysql://localhost:3306/user?characterEncoding=UTF-8";
        dbUser="root";
        dbPassword="111";
        try {
            Class.forName(dbDriver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    static public Connection getConnection() throws SQLException {

        Connection connection = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
        return  connection;
    }

    static public void closeConnection(Connection con) {
        try {
            con.close();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

}
